import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import be.ac.ulg.montefiore.run.jahmm.Hmm;
import be.ac.ulg.montefiore.run.jahmm.ObservationVector;
import be.ac.ulg.montefiore.run.jahmm.io.FileFormatException;
import be.ac.ulg.montefiore.run.jahmm.io.HmmReader;
import be.ac.ulg.montefiore.run.jahmm.io.OpdfVectorReader;

public class TestHMM {

	/**
	 * @param args
	 */
	public static final String HMM_WRAPPER = "HMM_WRAPPER";
	public static final String HMM_MODEL = "HMM_MODEL";
	public static final String HEADER_FILE_NAME = "HEADER_FILE_NAME";
	public static final String SEQUENCE_LENGTH = "SEQUENCE_LENGTH";
	public static final int CACHE_LIMIT = 10;
	protected Hmm<ObservationVector> hmm;
	protected int numObservationValues;
	protected int sequenceLength;
	protected List<String> OUTPUT_NAMES;
	protected List<String> INPUT_NAMES;
	private String headerFileName;
	private String hmmModelFileName;

	public void HmmWrapper(String headerFileName, String hmmModelFileName,
			int sequenceLength) {
		loadHeaderInfo(headerFileName);
		try {
			this.hmm = HmmReader.read(new FileReader(hmmModelFileName),
					new OpdfVectorReader());
		} catch (FileFormatException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void loadHeaderInfo(String fileName) {
		this.INPUT_NAMES = new ArrayList();
		this.OUTPUT_NAMES = new ArrayList();

		Properties properties = new Properties();
		try {
			properties.load(new FileInputStream(fileName));

			this.numObservationValues = Integer.parseInt(properties
					.getProperty("numObservationValues"));

			String[] inputNames = properties.getProperty("observationVector")
					.split(",");
			for (String name : inputNames) {
				this.INPUT_NAMES.add(name.trim());
			}

			String[] outputNames = properties.getProperty("states").split(",");
			for (String name : outputNames)
				this.OUTPUT_NAMES.add(name.trim());
		} catch (IOException localIOException) {
		}
	}

}
